//
// Created by Administrator on 2022/2/22.
//
#include "t_pure_vitural_function_class.h"

namespace pure_vitrual_func_class_test{

    //测试函数
    void test(){
      AcctABC *p_clients[CLIENTS];
      string temp;
      long tempnum;
      double tempbal;
      char kind;

        //类似java的interface接口，不可以实例化
        //AcctABC interfaceABC;

        for (int i=0; i < CLIENTS; i++){
            cout<<"Enter client`s name:";
            std::getline(cin,temp);
            cout<<"Enter client`s account number:";
            cin>>tempnum;
            cout<<"Enter opening balance$:";
            cin>>tempbal;
            cout<<"Enter 1 for Brass Account or 2 for BrassPlus Account.";
            while (cin>>kind && (kind != '1' && kind != '2')){
                cout<<"Enter 1 or 2:";
            }
            if(kind  == '1'){
               p_clients[i] = new Brass(temp,tempnum,tempbal);
            }
            else if(kind  == '2'){
               double tmax,trate;
               cout<<"Enter the interest rate:";
               cout<<"as a decimal fraction:";
               cin>>trate;
               p_clients[i] = new BrassPlus(temp,tempnum,tempbal,tmax,trate);
            }

            //next
            while (cin.get() != '\n'){
                continue;
            }
        }


        cout<<endl;
        for (int i = 0; i < CLIENTS; ++i) {
            p_clients[i]->ViewAcct();
            cout<<endl;
        }

        //垃圾回收
        for (int i = 0; i < CLIENTS; ++i) {
            delete p_clients[i];
        }

        cout<<"Done."<<endl;

    }
}
